<?php

namespace app\admin\controller\workteam;

use app\common\controller\Backend;

/**
 * 共有的一些不需要权限的接口
 * @internal
 */
class Common extends Backend
{
    protected $noNeedRight = ['selectpage'];
    public function _initialize()
    {
        parent::_initialize();
        //设置过滤方法
        $this->request->filter(['trim', 'strip_tags', 'htmlspecialchars']);
    }

    /**
     * 下拉选择
     * @fun
     * @Internal
     */
    public function selectpage(){
        $modellist=['admin'];
        $model = $this->request->param('model');
        if (!$this->request->request('keyField')){
            $this->error("访问出错");
        }
        if (!in_array($model,$modellist))
            $this->error("非法访问");

        $this->model = model($model);
        $type = $this->request->param('type');


        switch ($model){
            case 'admin':
                $custom=[];
                $custom['status']='normal';
                if ($type != "all") {
                    $auth = new \addons\workteam\library\Auth();
                    $childrenAdminIds=$auth->childrenAdminIds($this->auth,true);
                    $custom['id']=['in', $childrenAdminIds];
                }
                $this->request->request(['custom' => $custom]);
                break;
        }
        return parent::selectpage();
    }


}
